/**
 * Class: FVector3
 *
 * Purpose: 
 *
 * Created: Jan 23, 2010 @ 11:06:19 PM
 * @author Ken Scott
 */
package org.openfantasia.util.math;

import org.openfantasia.util.Copyable;

public class FVector3 implements Copyable<FVector3> {

	private static final int N = 3;

	public float p[][][];


	public FVector3() {
		p = new float[N][N][N];
	}


	public FVector3(float[][][] p) {
		if (p[0][0].length != N) {
			throw new IllegalArgumentException("Input array must be of length " + N + ", not " + p[0][0].length);
		}
		this.p = Math3D.copy(p);
	}


	public FVector3(FVector3 p) {
		this(p.p);
	}


	public FVector3 copy() {
		return new FVector3(p);
	}


	public void copy(FVector3 that) {
		p = Math3D.copy(that.p);
	}


	public FVector3 clear() {
		Math3D.fill(p, 0f);
		return this;
	}


	public float[][][] getValue() {
		return p;
	}


	public FVector3 neg() {
		p = Math3D.neg(p);
		return this;
	}


	public FVector3 abs() {
		p = Math3D.abs(p);
		return this;
	}


	public FVector3 add(FVector3 a) {
		if (a == null) {
			return this;
		}

		p = Math3D.add(p, a.p);
		return this;
	}


	public FVector3 sub(FVector3 a) {
		if (a == null) {
			return this;
		}

		p = Math3D.sub(p, a.p);
		return this;
	}


	public FVector3 mul(FVector3 a) {
		if (a == null) {
			return this;
		}

		p = Math3D.mul(p, a.p);
		return this;
	}


	public FVector3 div(FVector3 a) {
		if (a == null) {
			return this;
		}

		p = Math3D.div(p, a.p);
		return this;
	}
}